﻿#region using statements

using AeonOfStrife.States;

using Microsoft.Xna.Framework;

using NGen;
using NGen.Managers.GUI;
using NGen.Managers.GameState;

using Nuclex.UserInterface;
using Nuclex.UserInterface.Controls.Desktop;

#endregion

namespace AeonOfStrife.GUI.Layouts
{
	/// <summary>
	/// 	The gui used in the menu stats
	/// </summary>
	public class GUILayoutMenu : GUIElement
	{
		#region local fields

		//buttons in the gui
		private readonly ButtonControl m_creditsButton = new ButtonControl();

		private readonly ButtonControl m_helpButton = new ButtonControl();

		private readonly ButtonControl m_optionsButton = new ButtonControl();

		private readonly ButtonControl m_playButton = new ButtonControl();

		private readonly ButtonControl m_quitButton = new ButtonControl();

		#endregion

		#region GUIElement implementation

		/// <summary>
		/// 	_Initialize this gui
		/// </summary>
		protected override void _Initialize() {
			//create and wire up the buttons, add then to the list of children 
			//which belong to this gui
			m_playButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.3f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
			m_playButton.Text = "Play";
			m_playButton.Pressed += delegate { GameEngine.GetService<IManagerGameState>().ChangeState(new GameStatePlay()); };
			_Children.Add(m_playButton);

			m_helpButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.375f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
			m_helpButton.Text = "How to Play";
			m_helpButton.Pressed += delegate { GameEngine.GetService<IManagerGUI>().AddElement(new GUILayoutHelp()); };

			_Children.Add(m_helpButton);

			m_optionsButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.45f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
			m_optionsButton.Text = "Options";
			m_optionsButton.Pressed += delegate { GameEngine.GetService<IManagerGUI>().AddElement(new GUILayoutOptions()); };
			_Children.Add(m_optionsButton);

			m_creditsButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.525f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
			m_creditsButton.Text = "Credits";
			m_creditsButton.Pressed += delegate {
			                           	//GameEngine.GetService<IManagerGUI>().AddElement(new GUIElementCreditsWindow());
			                           };
			_Children.Add(m_creditsButton);

			m_quitButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.6f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
			m_quitButton.Text = "Quit";
			m_quitButton.Pressed += delegate { GameEngine.Exit(); };
			_Children.Add(m_quitButton);
		}

		/// <summary>
		/// 	Update this gui
		/// </summary>
		/// <param name = "p_gameTime">snapshot of timing values</param>
		protected override void Update(GameTime p_gameTime) {
			//nothing to update
		}

		/// <summary>
		/// 	Cleanup this gui
		/// </summary>
		protected override void _Cleanup() {
			//no cleanup necessary outside of the normal memory deallocation
			//C# takes care of this via garbage collection
		}

		#endregion
	}
}